package wzh000;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;


public class ImageDisplayer extends JPanel{
	private BufferedImage img;
	private File input;
	public ImageDisplayer() throws IOException{
		this.input = new File("zw.jpg");
		
		
	}
	public void setImg(BufferedImage img){
		this.img = img;
	}
	
	public void paint(Graphics g){
		g.drawImage( this.img, 0, 0, null);
	}
	
	public int getHeight(){
		return img.getHeight();
	}
	
	public int getWidth(){
		return img.getWidth();
	}
	
	public void load() throws IOException{
		
	}
	
	public void close(){
		
	}
	
	
	

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
		JFrame frame = new JFrame("My GUI");
		JPanel panel = new ImageDisplayer();
		frame.getContentPane().add(panel);
		frame.setSize(panel.getWidth(),panel.getHeight());
		frame.setResizable(false);
		frame.setVisible(true);
		frame.setLocationRelativeTo(null);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		/*
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(200, 50);
		frame.setResizable(false);
		frame.setLocationRelativeTo(null);
		
		// Inserts the image icon
		String imgStr = "wcam0_20030322_1245.jpg";
			
			
		ImageIcon image = new ImageIcon(imgStr);
		JLabel label1 = new JLabel(" ", image, JLabel.CENTER);
		frame.getContentPane().add(label1);
		
		frame.validate();
		frame.setVisible(true);
		*/
	}

}
